package org.yang.common.i18n.result;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.yang.common.i18n.enums.RI18nEnum;
import org.yang.common.i18n.utils.I18nUtils;

import java.io.Serializable;

/**
 * @author: lslands
 * @version: 1.0
 * @create: 2024/5/18
 * @description:
 */
@Data
@NoArgsConstructor
public abstract class ResultI18n implements Serializable {

    /**
     * 返回信息
     * @mock 成功
     */
    private String message;

    /**
     * 国际化扩展字段
     */
    @JsonIgnore
    private transient String[] local;

    /**
     * 默认文字
     */
    @JsonIgnore
    private transient String defaultMsg;

    public ResultI18n(String message) {
        this.message = I18nUtils.message(message);;
    }
    public ResultI18n(RI18nEnum ri18nEnum) {
        this.message = I18nUtils.message(ri18nEnum);
    }
    public ResultI18n(String message, String... local) {
        this.message = I18nUtils.message(message,null,local);
    }
    public ResultI18n(RI18nEnum nEnum, String... local) {
        this.message = I18nUtils.message(nEnum.getLocalMsg(), null,local);
    }
}
